package com.cy.pj.brand.service.impl;

import com.cy.pj.brand.dao.BrandDao;
import com.cy.pj.brand.pojo.Brand;
import com.cy.pj.brand.service.BrandService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BrandServiceImpl implements BrandService {
    private static final Logger log = LoggerFactory.getLogger(BrandServiceImpl.class);

    @Autowired
    private BrandDao brandDao;

    @Override
    public List<Brand> findBrands(String name) {
        long start = System.currentTimeMillis();
        List<Brand> list = brandDao.findBrands(name);
        long end = System.currentTimeMillis();
        log.info("执行时间：{}", end - start);
        return list;
    }

    @Override
    public int deleteById(Integer id) {
        return brandDao.deleteById(id);
    }

    @Override
    public int saveBrand(Brand brand) {
        return brandDao.insertBrand(brand);
    }

    @Override
    public Brand findById(Integer id) {
        return brandDao.findById(id);
    }

    @Override
    public int updateBrand(Brand brand) {
        return brandDao.updateBrand(brand);
    }
}
